set more off*set memory sizeclear set matsize 800cap set mem 300mrun programs.do/* We start with the original cses modules 1 and 2 datasets, which exist in separate subdirectories csesmod1 and csesmod2 *//* get cses files and prepare merged dataset *//* modify the cses module 2 data to match module 1 */    /*  Load the cses module 2 data set.  */    use B1006 B1004 B1010_1 B2002 B2001 B1008 B2020 B2003 B1001 B3028 B3029_1 using  csesmod2.dta, clear

    *id component -- polity    rename B1006 A1006    *id variable-election study (alphabetic polity)    rename B1004 A1004    *weight    rename B1010_1 A1010_1    *sex    rename B2002 A2002    *age    rename B2001 A2001    *id component-election year    rename B1008 A1008    *income    rename B2020 A2012    *education    rename B2003 A2003    rename B1001 A1001    *are you close to any particular political party    rename B3028 A3004    *party closest to    rename B3029_1 A3005_1    /* save module 2 recoded */  tempfile csesmod2rec    save `csesmod2rec', replace/* use module 1 data */use A1001 A2001 A2012 A2002 A2003 A3031  A1006  A1010_1 A1008 A3004 A3005_1 using csesmod1.dta, cleardestring A1008, replacecapture drop *mergeappend using `csesmod2rec'*generate year of election variablegen year=A1008/* measuring PID *//* If we only care about whether or not the respondent has a party id, and not what party that respondent actually identifies with, we will use the following variable.  Simple_PID is when the respondent answers yes to A3004 and names a party for A3005_1.  This variable =1 if the Respondent has PID, 0 if they do not  */* Simple PIDgen simplepid=0replace simplepid=1 if A3004==1&A3005_1<=96&A3005_1>0/* We code as missing those with inconsitent responses */  replace simplepid=. if A3004>5keep A2001 A2012 A2002 A2003 A3031 simple A1006  A1010_1save csesmod1and2_small, replace
